<template>
  <div class="app-container">
    <el-row>
      <el-col :span="24" class="card-box">
        <el-card>
          <div slot="header"><span>评论过滤设置</span></div>
          <div class="el-table el-table--enable-row-hover el-table--medium">
            <el-form
              ref="form"
              :model="form"
              :rules="rules"
              label-width="80px"
              style="margin-bottom: 20px"
            >
              <el-form-item label="开启过滤">
                <el-radio-group v-model="form.isOpen">
                  <el-radio
                    v-for="dict in dict.type.sys_yes_no"
                    :key="dict.value"
                    :label="dict.value"
                    >{{ dict.label }}</el-radio
                  >
                </el-radio-group>
              </el-form-item>
              <el-row>
                <el-col :span="16">
                  <el-form-item
                    label="关键字"
                    prop="keyword"
                    style="margin-bottom: 0px"
                  >
                    <el-input
                      v-model="form.keyword"
                      type="textarea"
                      placeholder="请输入审核关键字，多个用英文,号隔开"
                      :autosize="{ minRows: 5, maxRows: 5 }"
                    />
                  </el-form-item>
                  <!-- 添加说明文字 -->
                  <span style="color: #999; margin-left: 80px">开启过滤后，评论含关键字的将需要人工手动审核，关键字多个用英文,号隔开</span
                  >
                </el-col>
              </el-row>
            </el-form>
            <div slot="footer" class="dialog-footer" style="margin-left: 80px;margin-bottom: 40px;">
              <el-button type="primary" @click="submitForm">保 存</el-button>
              <el-button @click="resetQuery">重 置</el-button>
            </div>
          </div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { getAudit, addAudit, updateAudit } from "@/api/article/audit";

export default {
  name: "Audit",
  dicts: ["sys_yes_no", "sys_normal_disable"],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 评论审核表格数据
      auditList: [],
      // 弹出层标题
      title: "",
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        status: null,
        open: null,
        keyword: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
    };
  },
  created() {
    this.getData();
  },
  methods: {
    /** 重置按钮操作 */
    resetQuery() {},
    /** 获得数据 */
    getData() {
      getAudit(1).then((response) => {
        console.log(response.data);
        this.form = response.data;
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.id != null) {
            updateAudit(this.form).then((response) => {
              this.$modal.msgSuccess("设置成功");
              this.getList();
            });
          }
        }
      });
    },
  },
};
</script>
